import json
from flask import jsonify
import numpy

def getJsonForData(data,is_json=True):
    if data is None:
        return "{}"
    # print(data)
    dit3 = {}
    # print(data)
    for x in data.columns:
        # if type(x) == "int64":
        #     x = 'code'+x
        dit2 = dict(data[x])
        for xx in dit2:
            # print(xx)
            if type(dit2[xx])==numpy.float64 or type(dit2[xx])==numpy.int64:
                dit2[xx] = str(dit2[xx])

        dit3[x] = dit2
    if is_json:
        json_str = json.dumps(dit3)
        return json_str
        # return jsonify(dit3)
    else:
        return dit3